using System.Reflection;
using Autofac;
using Core.Framework.CommonControllers;

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddControllers();

//添加本地缓存到IOC容器
builder.Services.AddMemoryCache();

// Add services to the container.
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();

//使用Commoncontroller项目模块
builder.Services.AddCommonControllers();

#region 添加数据库到IOC容器
// builder.Services.AddDbContext<>()
#endregion

#region Autofac程序集注入

var containter = new ContainerBuilder();
containter.RegisterAssemblyTypes(Assembly.GetExecutingAssembly()).AsImplementedInterfaces().PropertiesAutowired();

#endregion


var app = builder.Build();

// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
    app.UseSwagger();
    app.UseSwaggerUI();
}

app.UseHttpsRedirection();

app.MapControllers();

app.Run();
